#!/bin/bash

# 首选需要先安装zerotier
curl https://install.zerotier.com | bash && printf "\E[1;32m安装zerotier成功！\E[0m\n"

# 安装后，替换planet文件


wget --http-user=xieziqiang --http-password=xzq243715560  \
	--no-check-certificate \
	--output-document=/root/planet \
	-v https://www.xieziqiang.cn:3443/files/zerotier/planet

systemctl stop zerotier-one.service

\cp -a /var/lib/zerotier-one/planet /var/lib/zerotier-one/planet_bak
\cp /root/planet /var/lib/zerotier-one/planet

systemctl enable --now zerotier-one.service

sleep 5
# 加入zerotier私有网络
zerotier-cli join "2c332f4a00e6ef54"

printf "等待一分钟..."
sleep 10
printf "..."
sleep 10
printf "..."
sleep 10
printf "..."
sleep 10
printf "..."
sleep 10
printf "..."
sleep 10
printf "...\n"
ping -c1 -w10 192.168.210.1 && printf "\E[1;32m已联通192.168.210私有网络！\E[0m\n"

zerotier-cli orbit 49c0f6ea26 49c0f6ea26

zerotier-cli orbit 451fa412a9 451fa412a9

printf "\E[1;32m局域网IP为: %s\E[0m\n" $(ip a | grep "192.168.210" | tr -s ' '|awk -F' |/' '{print $3}')
